// Package vehicle_model 模型
package vehicle_model

import (
	// "gitee.com/sweetsunnyflower/carpooling-server-go/pkg/logger"
	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/database"
)

type VehicleModel struct {
	models.BaseModel
	BrandId uint64 `gorm:"column:brand_id" db:"brand_id" json:"brand_id" form:"brand_id"`
	Name    string `gorm:"type:varchar(255)" db:"name" json:"name" form:"name"`
	Year    int    `gorm:"column:year" db:"year" json:"year" form:"year"`

	models.CommonTimestampsField
}

func (vehicleModel *VehicleModel) Create() {
	database.DB.Create(&vehicleModel)
}

func (vehicleModel *VehicleModel) Save() (rowsAffected int64) {
	result := database.DB.Save(&vehicleModel)
	return result.RowsAffected
}

func (vehicleModel *VehicleModel) Delete() (rowsAffected int64) {
	result := database.DB.Delete(&vehicleModel)
	return result.RowsAffected
}
